<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:variable name="url" select="'http://www.mindcontrol.org/~hplus/nusite/'"/>

  <xsl:template match="article">
    <html>
      <head>
        <link href="default.css" rel="stylesheet" type="text/css"/>
        <title><xsl:value-of select="title"/></title>
      </head>
      <body>
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td width="550">
              <xsl:apply-templates select="text|code|image"/>
            </td>
            <td width="40"> </td>
            <td width="160">
              <p><script type="text/javascript" language="javascript">
                  google_ad_client = "pub-4859062516143083";
                  google_ad_width = 160;
                  google_ad_height = 600;
                  google_ad_format = "160x600_as";
                  google_ad_type = "text_image";
                  google_ad_channel ="";
                  google_page_url = document.location;
                  google_color_border = "999933";
                  google_color_bg = "CCCC99";
                  google_color_link = "0033FF";
                  google_color_url = "0033FF";
                  google_color_text = "000000";
                </script>
                <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
              </p>
            </td>
          </tr>
        </table>
        <br/><br/>
        <div id="tailad">
          <script type="text/javascript" language="javascript">
            google_ad_client = "pub-4859062516143083";
            google_ad_width = 728;
            google_ad_height = 90;
            google_ad_format = "728x90_as";
            google_ad_type = "text_image";
            google_ad_channel ="1169783957";
            google_page_url = document.location;
            google_color_border = "999933";
            google_color_bg = "CCCC99";
            google_color_link = "0033FF";
            google_color_url = "0033FF";
            google_color_text = "000000";
          </script>
          <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
        </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="text">
    <xsl:if test="@anchor != ''">
      <a><xsl:attribute name="name"><xsl:value-of select="@anchor"/></xsl:attribute></a>
    </xsl:if>
    <xsl:if test="@heading != ''">
      <h2><xsl:value-of select="@heading"/></h2>
    </xsl:if>
    <xsl:choose>
      <xsl:when test="span|ul|a|div">
        <p>
          <xsl:if test="@class != ''"><xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute></xsl:if>
          <xsl:apply-templates/>
        </p>
      </xsl:when>
      <xsl:otherwise>
        <p>
          <xsl:if test="@class != ''"><xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute></xsl:if>
          <xsl:value-of select="."/>
        </p>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="span">
    <span>
      <xsl:if test="@class != ''"><xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute></xsl:if>
      <xsl:value-of select="."/>
    </span>
    <xsl:if test="@break != ''"><br/></xsl:if>
  </xsl:template>

  <xsl:template match="div">
    <xsl:copy-of select="."/>
  </xsl:template>

  <xsl:template match="ul">
    <ul>
      <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
      <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
      <xsl:apply-templates/>
    </ul>
  </xsl:template>

  <xsl:template match="li">
    <li>
      <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
      <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
      <xsl:choose>
        <xsl:when test="span|ul|a">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="."/>
        </xsl:otherwise>
      </xsl:choose>
    </li>
  </xsl:template>
  
  <xsl:template match="a">
    <a>
      <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
      <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
      <xsl:value-of select="."/>
    </a>
  </xsl:template>

  <xsl:template match="code">
    <table cellspacing="1" cellpadding="10" class="codeframe">
      <tr class="codebg">
        <td><p><pre><xsl:value-of select="."/></pre>
            <br/><span style="font-size: 10px" class="code"><xsl:value-of select="@label"/></span></p>
        </td>
    </tr></table>
  </xsl:template>

  <xsl:template match="image">
    <p><img>
        <xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute>
        <xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute>
        <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
        <xsl:attribute name="height"><xsl:value-of select="@height"/></xsl:attribute></img>
      <br/>
      <span style="font-size: 10px"><xsl:value-of select="@label"/></span>
    </p>
  </xsl:template>
  
  <xsl:template match="sidebar">
    <html>
      <head>
        <link href="default.css" rel="stylesheet" type="text/css"/>
        <title>Navigation Sidebar</title>
      </head>
      <body background="sidebar1.png" bgcolor="#6c3a21" vlink="#ffffff" link="#ffffff" alink="#808080">
        <span class="sidebar">
          <h3 class="sidebar">By Keyword:</h3>
          <ul style="compact" class="sidebar">
            <xsl:apply-templates select="kw"/>
          </ul>
          <h3 class="sidebar">By Interest:</h3>
          <ul style="compact" class="sidebar">
            <xsl:apply-templates select="in"/>
          </ul>
        </span>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="spacer">
    <html>
      <head>
        <link href="default.css" rel="stylesheet" type="text/css"/>
        <title>Spacer</title>
      </head>
      <body><xsl:attribute name="background"><xsl:value-of select="@bgimage"/></xsl:attribute>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="kw">
    <li>
      <a>
        <xsl:attribute name="href"><xsl:value-of select="$url"/>?act=art_kw&amp;kw=<xsl:value-of select="@short"/></xsl:attribute>
        <xsl:attribute name="title"><xsl:value-of select="@long"/></xsl:attribute>
        <xsl:attribute name="target">Article</xsl:attribute>
        <xsl:value-of select="@long"/>
      </a>
    </li>
  </xsl:template>

  <xsl:template match="in">
    <li>
      <a>
        <xsl:attribute name="href"><xsl:value-of select="$url"/>?act=art_in&amp;in=<xsl:value-of select="@short"/></xsl:attribute>
        <xsl:attribute name="title"><xsl:value-of select="@long"/></xsl:attribute>
        <xsl:attribute name="target">Article</xsl:attribute>
        <xsl:value-of select="@long"/>
      </a>
    </li>
  </xsl:template>

  <xsl:template match="art-kw">
    <html>
      <head>
        <link href="default.css" rel="stylesheet" type="text/css"/>
        <title>Articles for keyword <xsl:value-of select="selected-keyword"/></title>
      </head>
      <body>
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td width="550">
              <table bgcolor="#808080" cellpadding="2" cellspacing="1" border="1">
                <xsl:for-each select="art">
                  <xsl:sort select="modified"/>
                  <tr>
                    <td>
                      <a>
                        <xsl:attribute name="href"><xsl:value-of select="$url"/>?act=main&amp;art=<xsl:value-of select="@filename"/></xsl:attribute>
                        <xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
                        <xsl:value-of select="@title"/>
                      </a>
                    </td>
                    <td>
                      <xsl:value-of select="@interests_short"/>
                    </td>
                    <td>
                      <xsl:value-of select="/art-kw/selected-keyword"/>
                    </td>
                    <td>
                      <xsl:value-of select="@modified"/>
                    </td>
                  </tr>
                </xsl:for-each>
              </table>
            </td>
            <td width="40"> </td>
            <td width="160">
              <p><script type="text/javascript">
                  google_ad_client = "pub-4859062516143083";
                  google_ad_width = 160;
                  google_ad_height = 600;
                  google_ad_format = "160x600_as";
                  google_ad_type = "text_image";
                  google_ad_channel ="";
                  google_page_url = document.location;
                  google_color_border = "999933";
                  google_color_bg = "CCCC99";
                  google_color_link = "0033FF";
                  google_color_url = "0033FF";
                  google_color_text = "000000";
                </script>
                <script type="text/javascript"
                  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
              </script></p>
            </td>
          </tr>
        </table>
        <br/>
        <a><xsl:attribute name="href"><xsl:value-of select="$url"/>?act=main</xsl:attribute>
          Show All Articles</a>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="art-in">
    <html>
      <head>
        <title>Articles for keyword <xsl:value-of select="selected-keyword"/></title>
        <link href="default.css" rel="stylesheet" type="text/css"/>
      </head>
      <body>
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td width="550">
              <table bgcolor="#808080" cellpadding="2" cellspacing="1" border="1">
                <xsl:for-each select="art">
                  <xsl:sort select="@modified"/>
                  <tr>
                    <td>
                      <a>
                        <xsl:attribute name="href"><xsl:value-of select="$url"/>?act=main&amp;art=<xsl:value-of select="@filename"/></xsl:attribute>
                        <xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
                        <xsl:value-of select="@title"/>
                      </a>
                    </td>
                    <td>
                      <xsl:value-of select="/art-in/selected-interest"/>
                    </td>
                    <td>
                      <xsl:for-each select="kw">
                        <xsl:value-of select="@short"/>,
                      </xsl:for-each>
                    </td>
                    <td>
                      <xsl:value-of select="@modified"/>
                    </td>
                  </tr>
                </xsl:for-each>
              </table>
            </td>
            <td width="40"> </td>
            <td width="160">
              <p><script type="text/javascript" language="text/javascript">
                  google_ad_client = "pub-4859062516143083";
                  google_ad_width = 160;
                  google_ad_height = 600;
                  google_ad_format = "160x600_as";
                  google_ad_type = "text_image";
                  google_ad_channel ="";
                  google_page_url = document.location;
                  google_color_border = "999933";
                  google_color_bg = "CCCC99";
                  google_color_link = "0033FF";
                  google_color_url = "0033FF";
                  google_color_text = "000000";
                </script>
                <script type="text/javascript"
                  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
              </script></p>
            </td>
          </tr>
        </table>
        <br/>
        <a><xsl:attribute name="href"><xsl:value-of select="$url"/>?act=main</xsl:attribute>
          Show All Articles</a>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="articles">
    <html>
      <head>
        <link href="default.css" rel="stylesheet" type="text/css"/>
        <title>Articles</title>
      </head>
      <body>
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td width="550">
              <table bgcolor="#808080" cellpadding="2" cellspacing="1" border="1">
                <xsl:for-each select="art">
                  <xsl:sort select="modified"/>
                  <tr>
                    <td>
                      <a>
                        <xsl:attribute name="href"><xsl:value-of select="$url"/>?act=main&amp;art=<xsl:value-of select="@filename"/></xsl:attribute>
                        <xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute>
                        <xsl:value-of select="@title"/>
                      </a>
                    </td>
                    <td>
                      <xsl:value-of select="@interests_short"/>
                    </td>
                    <td>
                      <xsl:for-each select="kw">
                        <xsl:value-of select="@short"/>,
                      </xsl:for-each>
                    </td>
                    <td>
                      <xsl:value-of select="@modified"/>
                    </td>
                  </tr>
                </xsl:for-each>
              </table>
            </td>
            <td width="40"> </td>
            <td width="160">
              <p><script type="text/javascript">
                  google_ad_client = "pub-4859062516143083";
                  google_ad_width = 160;
                  google_ad_height = 600;
                  google_ad_format = "160x600_as";
                  google_ad_type = "text_image";
                  google_ad_channel ="";
                  google_page_url = "" + document.location;
                  google_color_border = "999933";
                  google_color_bg = "CCCC99";
                  google_color_link = "0033FF";
                  google_color_url = "0033FF";
                  google_color_text = "000000";
                </script>
                <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
              </p>
            </td>
          </tr>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
